package cn.hotel.service.impl;

import cn.hotel.entity.Room;
import cn.hotel.mapper.RoomMapper;
import cn.hotel.service.RoomService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoomServiceImpl implements RoomService {
    @Resource
    private RoomMapper roomMapper;

    @Override
    public Room queryRoomByTypeId(String typeId) {
        return roomMapper.queryRoomByTypeId(typeId);
    }

    @Override
    public List<Room> queryAllRoomInfo() {
        return roomMapper.getAllRoomInfo();
    }

    @Override
    public PageInfo<Room> queryList(Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        PageInfo<Room> pageInfo = new PageInfo<>(roomMapper.getAllRoomInfo());
        return pageInfo;
    }

    @Override
    public void insertRoom(Room room) {
        roomMapper.insertRoom(room);
    }

    @Override
    public Room queryRoomInfoByRoomId(int roomId) {
        return roomMapper.queryRoomInfoByRoomId(roomId);
    }

    @Override
    public void updateRoomInfo(Room room) {
        roomMapper.updateRoomInfo(room);
    }

    @Override
    public void deleteRoomByRoomId(int roomId) {
        roomMapper.deleteRoomByRoomId(roomId);
    }
}
